package com.ruoyi.news.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.news.domain.XcxAddress;
import com.ruoyi.news.mapper.XcxAddressMapper;
import com.ruoyi.news.service.IXcxAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 小程序-用户地址Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-27
 */
@Service
public class XcxAddressServiceImpl implements IXcxAddressService
{
    @Autowired
    private XcxAddressMapper xcxAddressMapper;

    /**
     * 查询小程序-用户地址
     * 
     * @param id 小程序-用户地址主键
     * @return 小程序-用户地址
     */
    @Override
    public XcxAddress selectXcxAddressById(String id)
    {
        return xcxAddressMapper.selectXcxAddressById(id);
    }

    /**
     * 查询小程序-用户地址列表
     * 
     * @param xcxAddress 小程序-用户地址
     * @return 小程序-用户地址
     */
    @Override
    public List<XcxAddress> selectXcxAddressList(XcxAddress xcxAddress)
    {
        return xcxAddressMapper.selectXcxAddressList(xcxAddress);
    }

    /**
     * 新增小程序-用户地址
     * 
     * @param xcxAddress 小程序-用户地址
     * @return 结果
     */
    @Override
    public int insertXcxAddress(XcxAddress xcxAddress)
    {
        xcxAddress.setCreateTime(DateUtils.getNowDate());

        xcxAddressMapper.deleteXcxAddressByUserId(xcxAddress.getUserId());

        return xcxAddressMapper.insertXcxAddress(xcxAddress);
    }

    /**
     * 修改小程序-用户地址
     * 
     * @param xcxAddress 小程序-用户地址
     * @return 结果
     */
    @Override
    public int updateXcxAddress(XcxAddress xcxAddress)
    {
        xcxAddress.setUpdateTime(DateUtils.getNowDate());
        return xcxAddressMapper.updateXcxAddress(xcxAddress);
    }

    /**
     * 批量删除小程序-用户地址
     * 
     * @param ids 需要删除的小程序-用户地址主键
     * @return 结果
     */
    @Override
    public int deleteXcxAddressByIds(String[] ids)
    {
        return xcxAddressMapper.deleteXcxAddressByIds(ids);
    }

    /**
     * 删除小程序-用户地址信息
     * 
     * @param id 小程序-用户地址主键
     * @return 结果
     */
    @Override
    public int deleteXcxAddressById(String id)
    {
        return xcxAddressMapper.deleteXcxAddressById(id);
    }
}
